package forRecherche;

import objects.DocumentPondere;

/**
 * Represente un mot d'une requete (les mots sont maintenant ponderes)
 * @author louis
 *
 */
public class MotRequete implements Comparable<MotRequete> {


	private String mot;
	private float ponderation;
	
	public MotRequete(String mot, float d) {
		super();
		this.mot = mot;
		this.ponderation = d;
	}

	public String getMot() {
		return mot;
	}

	public void setMot(String mot) {
		this.mot = mot;
	}

	public float getPonderation() {
		return ponderation;
	}

	public void setPonderation(float ponderation) {
		this.ponderation = ponderation;
	}
	
	public String toString(){
		return "("+this.getMot()+" , "+this.getPonderation()+")";
	}
	
	public int compareTo(MotRequete doc) {
		if(this.getMot().equalsIgnoreCase(doc.getMot()) && this.getPonderation() == doc.getPonderation())
			return 0;
		else if (this.getPonderation()>doc.getPonderation())
			return 10;
		else
			return -10;
	}
	
	public boolean equals(Object other){
		if (other == null) return false;
	    if (!(other instanceof MotRequete))return false;
	    
	    MotRequete otherMyClass = (MotRequete)other;
		if(this.getMot().equalsIgnoreCase(otherMyClass.getMot()) && this.getPonderation() == otherMyClass.getPonderation())
			return true;
		else
			return false;
	}

}
